package com.xyy.saas.payment.callback.core.job;

import com.alibaba.fastjson.JSON;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import com.xyy.elasticjob.client.annotation.ElasticJobConf;
import com.xyy.saas.payment.common.HolidayService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import java.time.LocalDate;

/**
 * @author wangzeqi
 * 每个月15号晚上11点刷新节假日缓存
 */
@Slf4j
@ElasticJobConf(name = "HolidayRefreshJob", cron = "0 0 23 15 * ?")
@RequiredArgsConstructor
public class HolidayRefreshJob implements SimpleJob {

    private final HolidayService holidayService;

    @Override
    public void execute(ShardingContext shardingContext) {
        log.info("HolidayRefreshJob, started...shardingContext = {}", JSON.toJSONString(shardingContext));
        holidayService.refreshHolidayCache(LocalDate.now());
    }

}
